<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>修改订单</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/module_form.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/page_memberAdd.css">
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<script src="__PUBLIC__/Plugins/Datepicker/WdatePicker.js"></script>
<style>
.attr{
	margin-left:30px;
}
.editbtn{
	background-color:#339900;
	color:#FFFFFF;
	padding:2px 4px;
	cursor:pointer;
}
.ele_title{
	font-size:16px;
	font-weight:bold;
	width:108px;
}
.attr_list{
	background-color:green;
	margin-right:5px;
	color:#FFFFFF;
}
.module_form{
	margin-bottom:25px;
}
.module_form .kx{
	float:left;
	width:50%;
}
.module_form tr th , .module_form tr td{
	padding-left:10px;
}
</style>
</head>

<body>
	<div class="page_wraper">
	<form method="post" id="restaurantAdd_form">
		<div id="tab1_0" fortab="tab1">
			<table cellpadding="0" cellspacing="0" class="module_form" width="600">
				
				<input type="hidden" name="id" value="{$cid}"     />
				<volist name="list['gnfr']" id="vo" key="k" >
					<tr>
						<th colspan="2" id="pertentitle{$k}" rel="{$vo.entitle}">{$vo.title} <eq name="vo.ismust" value="1"><em class="color_main">* 必须选择</em></eq></th>		
					</tr>
					<tr>
						<eq name="vo.type" value="1">
							<input type="hidden" name="flag[{$k-1}][entitle]" value="{$vo.entitle}" />
							<input type="hidden" name="flag[{$k-1}][title]"   value="{$vo.title}" />
							<input type="hidden" name="flag[{$k-1}][xtype]"   value="{$vo.type}" />
							<td>
								<volist name="vo['config']" id="con" key="l">
									<div class="kx kx1 selectRadio{$k}" entitle="{$con.entitle}" title="{$con.title}" num="{$con.dnum}" price="{$con.mprice}" psprice="{$con.psprice}" key="{$k}" keys="{$l}">
										
										<php>if($attr[$k-1]['config']){</php>
											<input type="radio" name="kexuan{$k}" <php>if($attr[$k-1]['config'][$l-1]['title']&&$attr[$k-1]['config'][$l-1]['title']==$con['title']){</php>checked<php>}</php>/>
										<php>}else{</php>
											<eq name="vo.ismust" value="1">
												<input name="kexuan{$k}" type="radio" checked />
											<else />
												<input type="radio" name="kexuan{$k}" />
											</eq>
										<php>}</php>
										
										{$con.title}/{$con.entitle}<notempty name="con.mprice" >( 加 ￥{$con.mprice})</notempty>
										<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][title]"   id="ktitle{$k}{$l}"   
											<php>if($attr[$k-1]['config'][$l-1]['title']&&$attr[$k-1]['config'][$l-1]['title']==$con['title']){</php>value="{$con.title}"<php>}</php>/>
										<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][entitle]" id="kentitle{$k}{$l}" 
											<php>if($attr[$k-1]['config'][$l-1]['title']&&$attr[$k-1]['config'][$l-1]['title']==$con['title']){</php>value="{$con.title}"<php>}</php>/>
										<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][mprice]"  id="kprice{$k}{$l}"   
											<php>if($attr[$k-1]['config'][$l-1]['title']&&$attr[$k-1]['config'][$l-1]['title']==$con['title']){</php>value="{$con.title}"<php>}</php>/>
										<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][psprice]" id="kpsprice{$k}{$l}"   />
										<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][num]"     id="knum{$k}{$l}"     />
									</div>
								</volist>
								
							</td>
						</eq>
				 		<eq name="vo.type" value="2">
							<input type="hidden" name="flag[{$k-1}][entitle]"  value="{$vo.entitle}" />
							<input type="hidden" name="flag[{$k-1}][title]"    value="{$vo.title}"   />
							<input type="hidden" name="flag[{$k-1}][xtype]"    value="{$vo.type}"    />
							<td>
								<volist name="vo['config']" id="con" key="m">
									<div class="kx kx2" entitle="{$con.entitle}" title="{$con.title}" price="{$con.mprice}" psprice="{$con.psprice}" rel="check"  key="{$k}" keys="{$m}">
										<input type="checkbox" name="check{$k-1}[]" class="check" fenshu='ok' <neq name="attr[$k-1]['config'][$m-1]['title']" value="$m['title']">checked</neq>/>
										{$con.title}/{$con.entitle}<notempty name="con.mprice" >( 加 ￥{$con.mprice})</notempty>
										<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][title]"   id="ctitle{$k}{$m}"   
											<neq name="attr[$k-1]['config'][$m-1]['title']" value="$m['title']">value="{$con.title}"</neq>/>
										<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][entitle]" id="centitle{$k}{$m}" 
											<neq name="attr[$k-1]['config'][$m-1]['title']" value="$m['title']">value="{$con.entitle}"</neq>/>
										<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][num]"     id="cnum{$k}{$m}"     
											<neq name="attr[$k-1]['config'][$m-1]['title']" value="$m['title']">value="{$attr[$k-1]['config'][$m-1]['num']}"</neq>/>
										<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][mprice]"  id="cprice{$k}{$m}"   
											<neq name="attr[$k-1]['config'][$m-1]['title']" value="$m['title']">value="{$con.mprice}"</neq>/>
										<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][psprice]" id="cpsprice{$k}{$m}"   
											<neq name="attr[$k-1]['config'][$m-1]['title']" value="$m['title']">value="{$con.psprice}"</neq>/>
										 
										<select name="check_{$k}_num" id="xz{$k}{$m}" class="check_select" 
										<eq name="attr[$k-1]['config'][$m-1]['title']" value="$m['title']">style="display:none"</eq>>
											<for start="1" end="$con.maxnum" >
												<option value="{$i}" <eq name="attr[$k-1]['config'][$m-1]['num']" value="$i">selected</eq>>{$i}</option>
											</for>
										</select>
									</div>
								</volist>
							</td>
						</eq>
					</tr>
				</volist>
			</table>
		</div>
		</form>
	</div>
	<div class="page_footer pdtd10">
		<input type="button" name="submit" id="submit" value="确认"  class="form_ele_submit"/>
	</div>
</body>
<script type="text/javascript">
	//弹出窗口全局变量
	var api = frameElement.api, W = api.opener;
	$(function(){
		//滑动门
		$('.tabbar li').click(function(){
			var tabname = $('.tabbar>ul').attr('tabname');
			$('.tabbar li').removeClass('tabhover');
			$(this).addClass('tabhover');
			
			$('div[fortab="'+tabname+'"]').hide();
			$('#'+$(this).attr('show')).show();
		});
		
		//表格隔行换色
		$('.module_form tr:odd').addClass('odd');
		$('.module_form tr:even').addClass('even');
		
		//表单操作
		//重置
		$('.form_ele_reset').on('click',function(){
			$('#restaurantAdd_form').get(0).reset();
		});
		
		//提交
		$('.form_ele_submit').on('click',function(){
			
			var tipsObj = windowApi.lhgdialog.tips('正在提交数据...',2,etIcon.loading);
			
			//通过Ajax提交表单
			var postData = {};
			postData     = $("#restaurantAdd_form").serialize();
			
			$.post("{:U('Order/attrcart')}", postData ,function(data){
				if(data.status==1){
					//Ajax通讯成功后处理
					var api = frameElement.api;
					var obj = api.get('Order_add');
					obj.document.getElementById('clickproduct').click();
					frameApi.close(); //关闭当前窗口
				}else{
					windowApi.lhgdialog.alert(data.info);
				}
			}, "json");
		});
		
		//复选框选中时，出现下拉列表
		$('.check').click(function(){
			if($(this).attr('checked')){
				$(this).siblings('.check_select').show();
				$(this).siblings('.check_select').val('1');
			}else{
				$(this).siblings('.check_select').hide();	
			}
		});
		
		$(".kx1").each(function(i){
			var key      = $(this).attr("key");
			var keys     = $(this).attr("keys");
			var title    = $(this).attr("title");
			var entitle  = $(this).attr("entitle");
			var num      = $(this).attr("num");
			var price    = $(this).attr("price");
			var psprice  = $(this).attr("psprice");
			var obj = $(this).children("input[type=radio]").attr("checked");
			if(obj){
				$("#ktitle"+key+keys).val(title);
				$("#kentitle"+key+keys).val(entitle);
				$("#knum"+key+keys).val(num);
				$("#kprice"+key+keys).val(price);
				$("#kpsprice"+key+keys).val(psprice);
			}
			$(this).children("input[type=radio]").on("click",function(){
				$('.selectRadio'+key).each(function(){
					 $(this).children("input[type=hidden]").val("");
				 })
				if($(this).attr("checked")){
					$("#ktitle"+key+keys).val(title);
					$("#kentitle"+key+keys).val(entitle);
					$("#knum"+key+keys).val(num);
					$("#kprice"+key+keys).val(price);
					$("#kpsprice"+key+keys).val(psprice);
				}
			});
		});
		
		$(".kx2").each(function(j){
			var title   = $(this).attr("title");
			var entitle = $(this).attr("entitle");
			var price   = $(this).attr("price");
			var psprice = $(this).attr("psprice");
			var key     = $(this).attr("key");
			var keys    = $(this).attr("keys");
			$(this).children("input[type=checkbox]").on("click",function(){
				if($(this).attr("checked")){
					$("#ctitle"+key+keys).val(title);
					$("#centitle"+key+keys).val(entitle);
					$("#cprice"+key+keys).val(price);
					$("#cpsprice"+key+keys).val(psprice);
					$("#cnum"+key+keys).val("1");
					$("#xz"+key+keys+">option").each(function(h){
						$(this).live("click",function(){
							$("#cnum"+key+keys).val($(this).val());
						});
					});
				}else{
					$("#ctitle"+key+keys).val("");
					$("#centitle"+key+keys).val("");
					$("#cprice"+key+keys).val("");
					$("#cpsprice"+key+keys).val("");
				}
			});
			$("#xz"+key+keys+">option").each(function(h){
				$(this).live("click",function(){
					$("#cnum"+key+keys).val($(this).val());
				});
			});
		});
	});
</script>
</html>
